// pages/whole-detail/whole-detail.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null,
    info: {},
    // 轮播图参数
    banner: [],
    housing_types: {
      1: '小区住宅',
      2: '公寓'
    },
    room_type: {
      1: '押一付一',
      2: '押一付二',
      3: '押一付三',
      4: '押二付一',
      5: '押二付二',
      6: '押二付三',
      7: '半年付',
      8: '年付'
    },
    imgDomain: app.data.imgDomain,
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    circular: true,
    interval: 2000,
    duration: 500,
    previousMargin: 0,
    nextMargin: 0,
    // // 测试数据
    // location: {
    //   lat: 26.09982,
    //   lng: 119.29659
    // }, 
    // markers: [{
    //   // iconPath: "/resources/others.png",
    //   id: 0,
    //   latitude: 26.09982,
    //   longitude: 119.39659,
    //   width: 50,
    //   height: 50
    // }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({userInfo: app.globalData.userInfo})
    this.getData(options.id)
    //this.getLocation()
  },
  // openLocation: function () {
  //   console.log(this)
  //   wx.openLocation({
  //     latitude: this.data.location.lat,
  //     longitude: this.data.location.lng,
  //     scale: 28
  //   })
  // },
  // getLocation: function() {
  //   wx.getLocation({
  //     success: res => {
  //       console.log(res)
  //       this.setData({
  //         location: {
  //           lat: res.latitude,
  //           lng: res.longitude
  //         }
  //       })
  //     },
  //   })
  // },
  getData (id) {
    wx.showLoading()
    app.request('get', 'infoById', {id: id}, (r) => {
      this.setData({ info: r, banner: r.slider })
    })
  },
  callMobile (event) {
    let mobile = event.currentTarget.dataset.mobile
    console.log(mobile)
    wx.makePhoneCall({
      phoneNumber: mobile,
    }) 
  },
  login () {
    app.login(res => {
      this.setData({ userInfo: res })
    })
  },
  jump: function (event) {
    if (!event.currentTarget.dataset.jumpUrl) {
      return false;
    }
    wx.navigateTo({
      url: event.currentTarget.dataset.jumpUrl
    })
  }
})